<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<base href="<?php echo base_url(); ?>"/> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thống kê khách sạn</title>
<link rel="stylesheet" href="resources/admin/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/admin/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/admin/css/invalid.css" type="text/css" media="screen" />	
<link rel="stylesheet" href="resources/admin/css/south-street/jquery-ui-1.8.22.custom.css" type="text/css" />
<script type="text/javascript" src="resources/admin/scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="resources/admin/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="resources/admin/scripts/facebox.js"></script>
<script type="text/javascript" src="resources/admin/scripts/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="resources/admin/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="resources/admin/scripts/jquery.date.js"></script>
<script type="text/javascript" src="resources/admin/scripts/js/jquery-ui-1.8.22.custom.min.js"></script>
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<style type="text/css">
	.ui-datepicker-calendar {
		display: none;
	}
</style>
<script  type="text/javascript">
  $(function()
  {	  
	  $('.dialog_link_huy').click(function()
	  {
		  var url = $(this).attr("href");
		  
		  $('#dialog_huy').dialog(
		  {
			  autoOpen: false,
			  modal: true,
			  buttons: 
			  {
				  "Hủy": function() 
				  {
					  $(this).dialog("close");
					  window.location = url;
				  },
				  "Không": function() 
				  {
					  $(this).dialog("close");
				  }
			  }
		  });
		  
		  $('#dialog_huy').dialog('open');
		  
		  return false;
	  }); 
	  
  });
  
	function clearText(field)
	{
    	if (field.defaultValue == field.value) field.value = '';
	    else if (field.value == '') field.value = field.defaultValue;
	}
	
	$(document).ready(function() {
	   $('#txtDate1').datepicker({
			 changeMonth: true,
			 changeYear: true,
			 dateFormat: 'mm/yy',
			   
			 onClose: function()
			 {
				var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
				var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
				$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
			 
			},
			beforeShow: function() {
			   if ((selDate = $(this).val()).length > 0) 
			   {
				  iYear = selDate.substring(3);
				  iMonth = selDate.substring(0,2);
				  $(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 0));
				  $(this).datepicker('setDate', new Date(iYear, iMonth, 0));
			   }
    		}
	  });
	  $('#txtDate2').datepicker({
			 changeMonth: true,
			 changeYear: true,
			 dateFormat: 'mm/yy',
			   
			 onClose: function()
			 {
				var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
				var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
				$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
			 },
			beforeShow: function() {
			   if ((selDate = $(this).val()).length > 0) 
			   {
				  iYear = selDate.substring(3);
				  iMonth = selDate.substring(0,2);
				  $(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 0));
				  $(this).datepicker('setDate', new Date(iYear, iMonth, 0));
			   }
    		}
	  });
	});
	
	function Check()
	{
		var date1 = document.getElementById('txtDate1').value;
		var date2 = document.getElementById('txtDate2').value

		var m1 = date1.substr(0,2);
		var y1 = date1.substr(3);
		var m2 = date2.substr(0,2);
		var y2 = date2.substr(3);

		if(date1 != "" && date2 != "")
		{
			if(y1 < y2 || (y1 == y2 && m1 <= m2))
			{
				var loai = 0;
				if(document.getElementById("loai1").checked)
					loai = 1;
				if(document.getElementById("loai2").checked)
					loai = 2;
				if(document.getElementById("loai3").checked)
					loai = 3;
				var loaiks = document.getElementById("loaiks").value;

				var date1 = m1 + "_" + y1;
				var date2 = m2 + "_" + y2;
				document.getElementById("btn_baocao").href = 'index.php/baocao/baocaokhachsan/' + loai + "/" + loaiks + "/" + date1 + "/" + date2;
				document.getElementById("btn_baocao").click();
			}
			else
			{
				
			}
		}
	}
	
	function clickme()
	{
		var date1 = document.getElementById('txtDate1').value;
		var date2 = document.getElementById('txtDate2').value

		var m1 = date1.substr(0,2);
		var y1 = date1.substr(3);
		var m2 = date2.substr(0,2);
		var y2 = date2.substr(3);

		if(date1 != "" && date2 != "")
		{
			if(y1 < y2 || (y1 == y2 && m1 <= m2))
			{
				var loai = 0;
				if(document.getElementById("loai1").checked)
					loai = 1;
				if(document.getElementById("loai2").checked)
					loai = 2;
				if(document.getElementById("loai3").checked)
					loai = 3;
				var loaiks = document.getElementById("loaiks").value;

				var date1 = m1 + "_" + y1;
				var date2 = m2 + "_" + y2;
				document.getElementById("download").href = 'index.php/baocao/downloadks/' + loai + "/" + loaiks + "/" + date1 + "/" + date2;
				//document.getElementById("btn_baocao").click();
			}
			else
			{
				
			}
		}
	}
	
	function Clear(id)
	{
		document.getElementById(id).value = "";
	}
</script>
</head>
	<body><div id="body-wrapper"> <!-- Wrapper for the radial gradient background -->
		
		<div id="sidebar"><div id="sidebar-wrapper"> <!-- Sidebar with logo and menu -->
			
			<h1 id="sidebar-title"><a href="#">Simpla Admin</a></h1>
		  
			<!-- Logo (221px wide) -->
			<a href="#"><img id="logo" src="resources/admin/images/logo.png" alt="Simpla Admin logo" /></a>
		  
			<!-- Sidebar Profile links -->
			<div id="profile-links">
				Chào, <a href="#" title="Xem thông tin cá nhân"><?php echo $current_username; ?></a><br />
				<br />
				<a href="index.php/home/index" title="Xem trang i12" target="_blank">Xem Trang chủ</a> | <a href="index.php/login/logoutadmin" title="Đăng xuất">Thoát</a>
			</div>        
			
			<ul id="main-nav">  <!-- Accordion Menu -->
         		<?php
				if($chucvu == 'Nhân viên' || $chucvu == 'Quản lý' || $chucvu == 'Admin')
				echo
						"<li>
							<a href='index.php/phieudatphong/admin_index' class='nav-top-item no-submenu'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Đặt phòng
							</a>       
						</li>
				
						<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Khách sạn
							</a>
							<ul>
								<li><a href='index.php/phongtrongtheongay/admin_index'>Quản lý phòng trống</a></li>                    
								<li><a href='index.php/khachsan/admin_index'>Quản lý khách sạn</a></li>                        
								<li><a href='index.php/loaiphong/admin_index'>Quản lý loại phòng</a></li> <!-- Add class 'current' to sub menu items also -->
								<li><a href='index.php/loaigiuong/admin_index'>Quản lý loại giường</a></li>
							</ul>                           
						</li>
				
						<li>
							<a href='#' class='nav-top-item '> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Khuyến mãi
							</a>    
							<ul>
								<li><a href='index.php/thongtinkhuyenmai/admin_index'>Quản lý thông tin KM</a></li>                    
								<li><a href='index.php/thekhuyenmai/admin_index'>Quản lý thẻ KM</a></li> 
							</ul>                                                  
						</li>";
				
				if($chucvu == 'Quản lý' || $chucvu == 'Admin')
					echo
						"<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Nhà cung cấp
							</a> 
								<ul>                 
									<li><a href='index.php/nhacungcap/admin_index'>Nhà cung cấp hiện hành</a></li>
									<li><a href='index.php/nhacungcap/dangkymoi'>Danh sách đăng ký mới</a></li>
									<li><a href='index.php/nhacungcap/nccduyet'>Duyệt đăng ký</a></li>   
									<li><a href='index.php/nhacungcap/ngunghoptac'>Nhà cung cấp ngừng hợp tác</a></li>      
								</ul>         
						</li>
				
						<li>
							<a href='#' class='nav-top-item current'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Báo cáo thống kê
							</a>
								<ul>                 
									<li><a href='index.php/baocao/admin_index'>Thống kê doanh thu</a></li>
									<li><a class='current' href='index.php/baocao/baocaokhachsan'>Thống kê khách sạn</a></li>
								</ul>       
						</li>";
                
				if($chucvu == 'Admin')
					echo
						"
				
						<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Người dùng
							</a>
								<ul>                 
									<li><a href='index.php/nguoidung/admin_index'>Người dùng hiện hành</a></li>
									<li><a href='index.php/nguoidung/nddisable'>Người dùng disabling</a></li>
								</ul>        
						</li>
						<li>
							<a href='index.php/hethong/admin_index' class='nav-top-item no-submenu'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Hệ thống
							</a>       
						</li>";
			?>      
                
			</ul> <!-- End #main-nav -->
			
		</div></div> <!-- End #sidebar -->
		
		<div id="main-content"> <!-- Main Content Section with everything -->
			
			<noscript> <!-- Show a notification if the user has disabled javascript -->
				<div class="notification error png_bg">
					<div>
						Javascript is disabled or is not supported by your browser. Please <a href="http://browsehappy.com/" title="Upgrade to a better browser">upgrade</a> your browser or <a href="http://www.google.com/support/bin/answer.py?answer=23852" title="Enable Javascript in your browser">enable</a> Javascript to navigate the interface properly.
					</div>
				</div>
			</noscript>
			
			<!-- Page Head -->
            <div style="float:left; height:150px; width:55%; margin-top:10px; margin-bottom:20px;">
				<h2>Xin chào, <?php echo $current_username ?></h2>
				<p id="page-intro">Một ngày làm việc vui vẻ nhé !</p>
                <br />
                <br />

            </div>
            <div style="float:right;">
            	<img src="resources/admin/images/i12.png" />
            </div>
			
			<div class="clear"></div> <!-- End .clear -->
			
			<div class="content-box"><!-- Start Content Box -->
				
				<div class="content-box-header">
					
					<h3>Quản lý báo cáo thống kê</h3>
					
					<ul class="content-box-tabs">
						<li><a href="#tab1" class="default-tab">Doanh thu</a></li>
                        
						
					</ul>
					
					<div class="clear"></div>
					
				</div> <!-- End .content-box-header -->
				
				<div class="content-box-content">
					
					<div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
						
						<a href='index.php/baocao/baocaodoanhthu' id='btn_baocao'></a>
                         <?php // save tu den
						 	$maksselect = 0;
						
						 	if($baocaongayks != NULL)
							{
								$tu = $baocaongayks[0]->month . '/' . $baocaongayks[0]->year;
								foreach($baocaongayks as $row)
								{
									$den = $row->month . '/' . $row->year;
								}
								$maksselect = $baocaongayks[0]->maks;
								if(strlen($tu) == 6)
									$tu = '0' . $tu;
								if(strlen($den) == 6)
									$den = '0' . $den;
							}
							if($baocaongay != NULL)
							{
								$tu = $baocaongay[0]->month . '/' . $baocaongay[0]->year;
								foreach($baocaongay as $row)
								{
									$den = $row->month . '/' . $row->year;
								}
								if(strlen($tu) == 6)
									$tu = '0' . $tu;
								if(strlen($den) == 6)
									$den = '0' . $den;
							}
							if($baocaothangks != NULL)
							{
								$tu = $baocaothangks[0]->month . '/' . $baocaothangks[0]->year;
								foreach($baocaothangks as $row)
								{
									$den = $row->month . '/' . $row->year;
								}
								$maksselect = $baocaothangks[0]->maks;
								if(strlen($tu) == 6)
									$tu = '0' . $tu;
								if(strlen($den) == 6)
									$den = '0' . $den;
							}
							if($baocaothang != NULL)
							{
								$tu = $baocaothang[0]->month . '/' . $baocaothang[0]->year;
								foreach($baocaothang as $row)
								{
									$den = $row->month . '/' . $row->year;
								}
								if(strlen($tu) == 6)
									$tu = '0' . $tu;
								if(strlen($den) == 6)
									$den = '0' . $den;
							}
							if($baocaonam != NULL)
							{
								$minnam = $baocaonam[0]->year;
								$maxnam = $baocaonam[0]->year;
								foreach($baocaonam as $row)
								{
									if($minnam > $row->year)
										$minnam = $row->year;
									if($maxnam < $row->year)
										$maxnam = $row->year;
								}
								
								$minthang = 1;
								$maxthang = 12;
								foreach($baocaonam as $row)
								{
									if($row->year == $minnam && $minthang > $row->month)
									{
										$minthang = $row->month;
									}
									if($row->year == $maxnam && $maxthang < $row->month)
									{
										$maxthang = $row->month;
									}
								}
								$tu = $minthang . "/" . $minnam;
								$den = $maxthang . "/" . $maxnam;
								if(strlen($tu) == 6)
									$tu = '0' . $tu;
								if(strlen($den) == 6)
									$den = '0' . $den;
							}
							if($baocaonamks != NULL)
							{
								$minnam = $baocaonamks[0]->year;
								$maxnam = $baocaonamks[0]->year;
								foreach($baocaonamks as $row)
								{
									if($minnam > $row->year)
										$minnam = $row->year;
									if($maxnam < $row->year)
										$maxnam = $row->year;
								}
								
								$minthang = 1;
								$maxthang = 12;
								foreach($baocaonamks as $row)
								{
									if($row->year == $minnam && $minthang > $row->month)
									{
										$minthang = $row->month;
									}
									if($row->year == $maxnam && $maxthang < $row->month)
									{
										$maxthang = $row->month;
									}
								}
								
								$maksselect = $baocaonamks[0]->maks;
								$tu = $minthang . "/" . $minnam;
								$den = $maxthang . "/" . $maxnam;
								if(strlen($tu) == 6)
									$tu = '0' . $tu;
								if(strlen($den) == 6)
									$den = '0' . $den;
							}
						?>

						Thống kê theo:
             <input type="radio" id="loai1" name="loai" value="1" checked="checked" />Ngày &nbsp;&nbsp;
            <input type="radio" id="loai2" name="loai" value="2" <?php if($baocaothang != NULL || $baocaothangks != NULL) echo 'checked="checked"'; ?> />Tháng &nbsp;&nbsp; 
            <input type="radio" id="loai3" value="3" name="loai" <?php if($baocaonam != NULL || $baocaonamks != NULL) echo 'checked="checked"'; ?> />Năm &nbsp;&nbsp;
                        
             <select id='loaiks' onchange="Check()">
             	<option value="0"  <?php if($maksselect == 0) echo "selected='selected'" ?> >Tất cả</option>
                
			
             	<?php
					if($danhsachks != NULL)
					{
						$dsks = array();
						$i = 0;
						foreach($danhsachks as $row)
						{ 
							$tenks = $row->ten;
							$maks = $row->maks;
							$dsks[$i++] = $maks;
							if($maks == $maksselect)
								echo "<option value='$maks' selected='selected' >$tenks</option>";
							else
								echo "<option value='$maks' >$tenks</option>";
						}
					}
				?>
             </select>           
                        <br /><br />
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <label for="txtDate1">Từ :</label>
    					<input type='text' size="5" id='txtDate1' onfocus="Clear('txtDate1')" <?php if(isset($tu)) echo "value='$tu'";?>/>
                        <label for="txtDate2">đến :</label>
                        <input type='text' size="5" id='txtDate2' onfocus="Clear('txtDate2')" <?php if(isset($den)) echo "value='$den'";?>/>	
                        &nbsp;&nbsp;&nbsp;<a class='button' href='javascript:void(0);' onclick='Check()' >Thực hiện</a>
                        <?php
							if($baocaongayks != NULL)
							{
								$str = "<table>
												<thead>
													<tr>
														<th width='200px'>Khách sạn</th>
														<th>Năm</th>
														<th>Tháng</th>
														<th>Ngày</th>
														<th>Doanh thu (VNĐ)</th>
													</tr>
												</thead>";
								
								$temp1 = 0;
								$temp2 = 0;
								$t = 0;
								foreach($baocaongayks as $row)
								{
									$maks = $row->maks;
									$tenks = $row->tenks;
									$nam = $row->year;
									$thang = $row->month;
									$ngay = $row->day;
									$doanhthu = number_format($row->doanhthu * 1000, 0, '', '.');
									$t = 0;
									if($temp1 != $nam)
									{
										$temp1 = $nam;
										$temp2 = $thang;
										if($t == 0)
										{
											$str .= "<tr>
													<td><a href='index.php/khachsan/xemchitiet/$maks' title='Xem chi tiết'>$tenks</a></td>
													<td>$nam</td>
													<td>$thang</td>
													<td>$ngay</td>
													<td>$doanhthu</td>
													</tr>";
											$t = 1;
										}
										else
										{
											$str .= "<tr>
													<td>&nbsp;</td>
													<td>$nam</td>
													<td>$thang</td>
													<td>$ngay</td>
													<td>$doanhthu</td>
													</tr>";
										}
									}
									else
									{
										$str .= "<tr>
												<td>&nbsp;</td>
												<td>&nbsp;</td>";
										if($temp2 != $thang)
										{
											$temp2 = $thang;
											$str .= "<td>$thang</td>";
										}
										else
										{
											$str .= "<td>&nbsp;</td>";
										}
												$str .= "<td>$ngay</td>
														<td>$doanhthu</td>
														</tr>";
									}
								}
								
								echo $str;
							}
							if($baocaongay != NULL)
							{
								$str = "<table>
												<thead>
													<tr>
														<th width='200px'>Khách sạn</th>
														<th>Năm</th>
														<th>Tháng</th>
														<th>Ngày</th>
														<th>Doanh thu (VNĐ)</th>
													</tr>
												</thead>";
								
								
								foreach($dsks as $ks)
								{
									$temp1 = 0;
									$temp2 = 0;
									$t = 0;
									foreach($baocaongay as $row)
									{
										$maks = $row->maks;
										$tenks = $row->tenks;
										$nam = $row->year;
										$thang = $row->month;
										$ngay = $row->day;
										$doanhthu = number_format($row->doanhthu * 1000, 0, '', '.');
										if($maks == $ks)
										{
											if($temp1 != $nam)
											{
												$temp1 = $nam;
												$temp2 = $thang;
												if($t == 0)
												{
												$str .= "<tr>
														<td><a href='index.php/khachsan/xemchitiet/$maks' title='Xem chi tiết'>$tenks</a></td>
														<td>$nam</td>
														<td>$thang</td>
														<td>$ngay</td>
														<td>$doanhthu</td>
													</tr>";
												$t = 1;
												}
												else
												{
													$str .= "<tr>
														<td>&nbsp;</td>
														<td>$nam</td>
														<td>$thang</td>
														<td>$ngay</td>
														<td>$doanhthu</td>
													</tr>";
												}
											}
											else
											{
												$str .= "<tr>
														<td>&nbsp;</td>
														<td>&nbsp;</td>";
												if($temp2 != $thang)
												{
													$temp2 = $thang;
													$str .= "<td>$thang</td>";
												}
												else
												{
													$str .= "<td>&nbsp;</td>";
												}
												$str .= "<td>$ngay</td>
														<td>$doanhthu</td>
														</tr>";
												
											}
										}
									}
								}
								echo $str;
							}
							
							if($baocaothang != NULL)
							{
								$str = "<table>
												<thead>
													<tr>
														<th width='300px'>Khách sạn</th>
														<th>Năm</th>
														<th>Tháng</th>
														<th>Doanh thu (VNĐ)</th>
													</tr>
												</thead>";
								foreach($dsks as $ks)
								{
									$temp1 = 0;
									$t = 0;

									foreach($baocaothang as $row)
									{
										$maks = $row->maks;
										$tenks = $row->tenks;
										$nam = $row->year;
										$thang = $row->month;
										$doanhthu = number_format($row->doanhthu * 1000, 0, '', '.')." VNĐ";
										if($ks == $maks)
										{
											if($temp1 != $nam)
											{
												$temp1= $nam;
												if($t == 0)
												{
													$str .= "<tr>
																<td><a href='index.php/khachsan/xemchitiet/$maks' title='Xem chi tiết'>$tenks</a></td>
																<td>$nam</td>
																<td>$thang</td>
																<td>$doanhthu</td>
															</tr>";
													$t = 1;
												}
												else
												{
													$str .= "<tr>
																<td>&nbsp;</td>
																<td>$nam</td>
																<td>$thang</td>
																<td>$doanhthu</td>
															</tr>";
												}
											}
											else
											{
													$str .= "<tr>
																<td>&nbsp;</td>
																<td>&nbsp;</td>
																<td>$thang</td>
																<td>$doanhthu</td>
															</tr>";
											}
											
										}
									}
								}
								echo $str;
							}
							
							if($baocaothangks != NULL)
							{
								$str = "<table>
												<thead>
													<tr>
														<th width='300px'>Khách sạn</th>
														<th>Năm</th>
														<th>Tháng</th>
														<th>Doanh thu (VNĐ)</th>
													</tr>
												</thead>";
								$temp1 = 0;
								$t = 0;
								foreach ($baocaothangks as $row)
								{
									$maks = $row->maks;
									$tenks = $row->tenks;
									$nam = $row->year;
									$thang = $row->month;
									$doanhthu = number_format($row->doanhthu * 1000, 0, '', '.');
									if($temp1 != $nam)
									{
										if($t == 0)
										{
											$t = 1;
											$temp1 = $nam;
											$str .= "<tr>
														<td><a href='index.php/khachsan/xemchitiet/$maks' title='Xem chi tiết'>$tenks</a></td>
														<td>$nam</td>
														<td>$thang</td>
														<td>$doanhthu</td>
													</tr>";
										}
										else
										{
											$str .= "<tr>
														<td>&nbsp;</td>
														<td>$nam</td>
														<td>$thang</td>
														<td>$doanhthu</td>
													</tr>";
											$temp1 = $nam;
										}
									}
									else
									{
										$str .= "<tr>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>$thang</td>
														<td>$doanhthu</td>
													</tr>";
									}
								}
								echo $str;
							}
							
							if($baocaonam != NULL)
							{
								$str = "<table>
												<thead>
													<tr>
														<th>Tên khách sạn</th>
														<th>Năm</th>
														<th>Doanh thu (VNĐ)</th>
													</tr>
												</thead>";
								
								foreach ($dsks as $ks)
								{
									$temp = 0;
									$t = 0;
									foreach($baocaonam as $row)
									{
										$tenks = $row->tenks;
										$maks = $row->maks;
										$nam = $row->year;
										$doanhthu = number_format($row->doanhthu * 1000, 0, '', '.');
										if($ks == $maks)
										{
											
											if($t == 0)
											{
												$t = 1;
												$str .= "<tr>
															<td><a href='index.php/khachsan/xemchitiet/$maks' title='Xem chi tiết'>$tenks</a></td>
															<td>$nam</td>
															<td>$doanhthu</td>
														</tr>";
											}
											else
											{
												$str .= "<tr>
															<td>&nbsp;</td>
															<td>$nam</td>
															<td>$doanhthu</td>
														</tr>";
											}
											$temp = $nam;
										}
									}
									
								}
								echo $str;
							}
							if($baocaonamks != NULL)
							{
								$str = "<table>
												<thead>
													<tr>
														<th>Tên khách sạn</th>
														<th>Năm</th>
														<th>Doanh thu (VNĐ)</th>
													</tr>
												</thead>";
								$temp1 = 0;
								$t = 0;
								foreach ($baocaonamks as $row)
								{
									$maks = $row->maks;
									$tenks = $row->tenks;
									$nam = $row->year;
									$thang = $row->month;
									$doanhthu = number_format($row->doanhthu * 1000, 0, '', '.');
									
									if($t == 0)
									{
										$t = 1;
										$temp1 = $nam;
										$str .= "<tr>
													<td><a href='index.php/khachsan/xemchitiet/$maks' title='Xem chi tiết'>$tenks</a></td>
													<td>$nam</td>
													<td>$doanhthu</td>
												</tr>";
									}
									else
									{
										$str .= "<tr>
													<td>&nbsp;</td>
													<td>$nam</td>
													<td>$doanhthu</td>
												</tr>";
										$temp1 = $nam;
									}
									
								}
								echo $str;
							}
							
							
							
						?>
							
							<tbody>
                            
							</tbody>
							
						</table>
                        
                         <?php
					  if(isset($str) && $str != "")
					  {
							$s = "<a class='button' href='' id='download' onclick='clickme()' >Download file</a>";
							echo $s;
					   }
						?>                     

          				<div id="dialog_huy" title="Xác nhận" style="display:none">
							Bạn thực sự muốn hủy nhà cung cấp này?
						</div>                             

          				<div id="dialog_thanhtoan" title="Xác nhận" style="display:none">
							Bạn thực sự muốn hủy nhà cung cấp này?
						</div>                        
						
					</div> <!-- End #tab1 -->
					
				</div> <!-- End .content-box-content -->
				
			</div> <!-- End .content-box -->
			
			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
						&#169; Copyright 2012 i12 | Powered by <a href="http://themeforest.net/item/simpla-admin-flexible-user-friendly-admin-skin/46073">Simpla Admin</a> | <a href="#">Top</a>
				</small>
			</div><!-- End #footer -->
			
		</div> <!-- End #main-content -->
	</div></body>
</html>